<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>显示隐藏文本框内容</title>
    <style>
        input {
            display: block;
            color: #999;
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <input type="text" value="手机">
    
    <script>
        var input = document.querySelector('input');
        //得到焦点
        input.onfocus = function(){
            if(input.value == '手机'){
                this.value = '';
            }
            this.style.color = '#333';
        }
        //失去焦点
        input.onblur = function(){
            // this.value = '手机';
            if(this.value == ''){
                this.value = '手机';
            }
            this.style.color = '#999';
        }
    </script>
</body>

</html>